package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper extends BaseMapper<Category> {
    
    /**
     * 根据父类别ID查询子类别
     */
    @Select("SELECT * FROM categories WHERE parent_category_id = #{parentCategoryId}")
    List<Category> findByParentCategoryId(@Param("parentCategoryId") Integer parentCategoryId);
    
    /**
     * 根据类别名称模糊查询
     */
    @Select("SELECT * FROM categories WHERE category_name LIKE CONCAT('%', #{keyword}, '%')")
    List<Category> findByCategoryNameContaining(@Param("keyword") String keyword);
} 